using System.IO;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using QuickTest.Core.Compilation;

namespace QuickTest.Tests.Core.Compilation
{
    [TestFixture]
    public class ProjectCompilerTests
    {
        #region TestData

        private const string OutputDirectory = TestUtils.TestDirectory + "/Output/";
        private const string OutputAssemblyName = "CompilationTestProject.dll";

        #endregion

        [Test]
        [Category("Integration")]
        public void Can_Compile_Project()
        {
            try
            {
                MSBuildCompilerTests.CreateCompilationTestProject();

                Project project = Project.Create(new FileUri(MSBuildCompilerTests.CompilationProjectFilePath));

                var projectCompiler = new CompileProject();

                projectCompiler.Compile(project, CompilerFactory.Create(), new DirectoryUri(OutputDirectory));

                Assert.That(File.Exists(string.Format("{0}/{1}", OutputDirectory, OutputAssemblyName)), Is.True, "Project should have compiled to the specified output directory.");
            }
            finally
            {
                TestUtils.DeleteTestFiles();
            }
        }
    }
}